package com.xueyi.system.auxiliary.manager.impl;

import com.xueyi.system.auxiliary.domain.query.AuxiliaryQuery;
import com.xueyi.system.auxiliary.domain.dto.AuxiliaryDto;
import com.xueyi.system.auxiliary.domain.po.AuxiliaryPo;
import com.xueyi.system.auxiliary.domain.model.AuxiliaryConverter;
import com.xueyi.system.auxiliary.mapper.AuxiliaryMapper;
import com.xueyi.system.material.domain.query.MaterialQuery;
import com.xueyi.system.material.domain.dto.MaterialDto;
import com.xueyi.system.material.domain.po.MaterialPo;
import com.xueyi.system.material.domain.model.MaterialConverter;
import com.xueyi.system.material.mapper.MaterialMapper;
import cn.hutool.core.util.ObjectUtil;

import java.io.Serializable;
import java.util.Collection;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.xueyi.common.web.entity.manager.impl.SubBaseManager;
import com.xueyi.system.auxiliary.manager.IAuxiliaryManager;
import org.springframework.stereotype.Component;

/**
 * 投入品信息管理 数据封装层处理
 *
 * @author yanhe
 */
@Component
public class AuxiliaryManager extends SubBaseManager<AuxiliaryQuery, AuxiliaryDto, AuxiliaryPo, AuxiliaryMapper, AuxiliaryConverter, MaterialQuery, MaterialDto, MaterialPo, MaterialMapper, MaterialConverter> implements IAuxiliaryManager {

    /**
     * 设置主子表中子表外键值
     */
    @Override
    protected void setForeignKey(LambdaQueryWrapper<MaterialPo> queryWrapper, LambdaUpdateWrapper<MaterialPo> updateWrapper, AuxiliaryDto auxiliary, Serializable key) {
        Serializable id = ObjectUtil.isNotNull(auxiliary) ? auxiliary.
        getMaterialId() :key;
        if (ObjectUtil.isNotNull(queryWrapper))
            queryWrapper.eq(MaterialPo::getId, id);
        else
            updateWrapper.eq(MaterialPo::getId, id);
    }
}